#ifndef __DB_H__
#define __DB_H__

#define SERVER "192.168.2.136"
#define PORT 3306
#define DB_USER "root"
#define DB_PASSWD "root"
#define DB_NAME "cloudfs"

#include <mysql/mysql.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

// 定义查询语句执行后的回调函数
typedef void (*QUERY_Handler)(char **cols, char **rowdata);

extern MYSQL *db;

extern bool connect_db();
extern int query_db(char *sql, QUERY_Handler callback);
extern int insert_db(char *sql);
extern int update_db(char *sql);
extern int delete_db(char *table, char *pk_column, char *pk_value);
extern void close_db();

#endif